﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PassengerSelectionCriteria.ascx.cs" Inherits="MTRC.ODMS.Web.SOM.UserControl.PassengerSelectionCriteria" %>
<%@ Register Assembly="APJ.Web.UI.WebControls" Namespace="APJ.Web.UI.WebControls" TagPrefix="APJ" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControlToolkit" %>
<%@ Register Src="~/UserControl/Menu/PageFoot.ascx" TagName="PageFoot" TagPrefix="WebStructure" %>
<%@ Register Src="~/UserControl/Menu/TabStrip.ascx" TagName="TabStrip" TagPrefix="WebStructure" %>
<%@ Register Src="~/UserControl/Menu/PageHead.ascx" TagName="PageHead" TagPrefix="WebStructure" %>
<%@ Register Src="~/UserControl/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="WebStructure" %>
<link href="<%=ResolveUrl("~/JqueryUICombox/jquery-ui.css")%>" rel="stylesheet" type="text/css" />
<script src="<%=ResolveUrl("~/jQuery/jquery-1.6.2.min.js")%>"  type="text/javascript"></script>
<script src="<%=ResolveUrl("~/JqueryUICombox/jquery-ui.js")%>" type="text/javascript"></script>
<script src="<%=ResolveUrl("~/JqueryUICombox/combox_nomatch.js")%>" type="text/javascript"></script>
<link id="CSSCursor" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    var PersonSelectdStation_CallBackValue = false;
    var PersonSelectCriteria_CallBackValue = false;
    function PersonSelectdStation(criteriaID) {
        window.showModalDialog("../Popup/PopupUserQueryStation.aspx?criteriaID=" + criteriaID + "&MenuID=" + '<%=ViewState["_menuID"] %>' + "&AllAccessStationID=" + '<%=ViewState["_allAccessStationID"] %>' + "&OtherAccessStationID=" + '<%=ViewState["_otherAccessStationID"] %>' + "&StationId=" + document.getElementById("hidStation").value, window, 'dialogHeight:380px;dialogWidth:720px;scroll:no');

        if (PersonSelectdStation_CallBackValue) {
            document.getElementById("<%=rdbmorestation.ClientID%>").checked = true;
            document.getElementById("<%=rdbStation.ClientID%>").checked = false;
            /* Comment by jack 20150827 for u181.1 */
            document.getElementById("<%=btnChangeStation.ClientID%>").click();
            /***************************************/
        }

//        if (PersonSelectdStation_CallBackValue && document.getElementById("hdnPersonHoldStationKye").value != document.getElementById("hidStation").value) {
//            document.getElementById("<%=rdbmorestation.ClientID%>").checked = true;
//        }

//        if (PersonSelectdStation_CallBackValue && document.getElementById("hdnPersonHoldStationKye").value == document.getElementById("hidStation").value) {
//            document.getElementById("<%=rdbStation.ClientID%>").checked = true;
//        }

//        if (!PersonSelectdStation_CallBackValue && document.getElementById("hdnPersonHoldStationKye").value == document.getElementById("hidStation").value)
//        {
//            document.getElementById("<%=rdbStation.ClientID%>").checked = true;
//        }

        return PersonSelectdStation_CallBackValue;
    }

    function SetCursor(url) {
        if ($(".custom-combobox input")) {
            if (
            ($(".custom-combobox input").val() != "" && $(".custom-combobox input").val() != document.getElementById("txtSelectedOU").value) ||
            ($(".custom-combobox input").val() == "" && document.getElementById("txtSelectedOU").value != "")
            ) {
                if ($(".custom-combobox input").val() != document.getElementById("txtSelectedOU").value != "") {
                    document.getElementById('CSSCursor').href = url;
                }
                SetStaffInfoEnabled(true);
            }
        }

    }

    function SetCursorEnabled(disabled) {

        var btnSave = document.getElementById("btnSave");
        var btnSaveas = document.getElementById("btnSaveas");
        var btnDelete = document.getElementById("btnDelete");
        //var rdbStation = document.getElementById("rdbStation");
        //var ddlStation = document.getElementById("ddlStation");
        //var rdbmorestation = document.getElementById("rdbmorestation");
        //var btnMorestation = document.getElementById("btnMorestation");
        var rdbDateRange = document.getElementById("rdbDateRange");
        var ddlDateRange = document.getElementById("ddlDateRange");
        var rdbByDate = document.getElementById("rdbByDate");
        var dtbFrom = document.getElementById("dtbFrom");
        var dtbTo = document.getElementById("dtbTo");

        if (btnSave) {
            btnSave.disabled = disabled;
        }
        if (btnSaveas) {
            btnSaveas.disabled = disabled;
        }
        if (btnDelete) {
            btnDelete.disabled = disabled;
        }
//        if (rdbStation) {
//            rdbStation.disabled = disabled;
//        }
//        if (ddlStation) {
//            ddlStation.disabled = disabled;
//        }
//        if (rdbmorestation) {
//            rdbmorestation.disabled = disabled;
//        }
//        if (btnMorestation) {
//            btnMorestation.disabled = disabled;
//        }
        if (rdbDateRange) {
            rdbDateRange.disabled = disabled;
        }

        if (ddlDateRange) {
            ddlDateRange.disabled = disabled;
        }
        if (rdbByDate) {
            rdbByDate.disabled = disabled;
        }
        if (dtbFrom) {
            dtbFrom.disabled = disabled;
        }
        if (dtbTo) {
            dtbTo.disabled = disabled;
        }
    }

    $(function () {
        InitCombobox();
    });

    function InitCombobox() {
        $(".comboboxCriteria").combobox();
        $("#toggle").click(function () {
            $(".comboboxCriteria").toggle();
        });
        $(".custom-combobox").css({ "height": "20px" });
        $(".custom-combobox input").css({ "width": "330px", "text-indent":"3px", "height": "18px", "line-height": "18px" });
        $(".custom-combobox a").css({ "width": "16px", "height": "20px", "position": "relative", "top": "-3px", "left": "-1px", "border-left": "0px" });
        //alert($("#txtSelectedOU").val());
        if ($("#txtSelectedOU").val() != "") {
            //if ($("#txtSelectedOU").val() == "Default Criteria") {
            if ($("#txtSelectedOU").val() == '<%=ViewState["DefaultCriteriaName"] %>') {//Add by jack 20160125 ISU11 fixed for harcode 'Default Criteria'
                $(".custom-combobox input").val('');
            } else {
                $(".custom-combobox input").val($("#txtSelectedOU").val());
            }
            SetCursorEnabled(false);
        } 
        else {
            $(".custom-combobox input").val('');
        }

        $(".custom-combobox input").mouseout(function () {
            document.getElementById("txtIsJSRuning").value = "false";
            if (document.getElementById("txtSelectedOU").value != $(".custom-combobox input").val()) {
                document.getElementById("txtSelectedOU").value = $(".custom-combobox input").val();
            }
        });
    }

    /*Comment by jack 20150909 for U180.5 */
    function OpenPopupCriteriaNew() {
        //window.showModalDialog("../Popup/PopupCriteriaNew.aspx?MenuID=" + '<%=ViewState["_menuID"] %>', window, 'dialogHeight:150px;dialogWidth:450px;scroll:no'); 
        window.showModalDialog("../Popup/PopupCriteriaNew.aspx?MenuID=" + '<%=ViewState["_menuID"] %>&DefaultCriteria=<%=ViewState["DefaultCriteriaName"] %>', window, 'dialogHeight:150px;dialogWidth:450px;scroll:no'); //Add by jack 20160125 ISU11 fixed for harcode 'Default Criteria'
        if (PersonSelectCriteria_CallBackValue) {
            document.getElementById("<%=btnChangeCriteria.ClientID%>").click();
        }
    }
</script>
<asp:UpdatePanel runat="server" ID="updatePanel3">
<ContentTemplate>
    <table>
    <tr>
        <td>
            <asp:Label ID="lblCriteria" Text="Criteria" runat="server"></asp:Label>
        </td>
        <td>
            <asp:DropDownList ID="ddlCriteria" runat="server" Width="330" AutoPostBack="true" CssClass="comboboxCriteria" OnSelectedIndexChanged="ddlCriteria_SelectedIndexChanged">
            </asp:DropDownList>
            <div style="display:none;">
                <%-- Comment by jack 20150909 for U180.5 --%>
                <asp:TextBox runat="server" ID="txtIsJSRuning" ClientIDMode="Static" Text="false"></asp:TextBox>
                <%--********************************--%>
                <asp:TextBox runat="server" ID="txtSelectedOU" ClientIDMode="Static" OnTextChanged="txtSelectedValue_OnTextChanged"  onpropertychange="if(document.getElementById('txtIsJSRuning').value=='true'){return;}else{__doPostBack('txtSelectedOU',null);}"></asp:TextBox>
            </div>
        </td>
        <td>
            <asp:Button ID="btnSave" Text="Save" ClientIDMode="Static" runat="server" OnClick="btnSave_Click" />&nbsp;&nbsp;
            <%-- Comment by jack 20150909 for U180.5 --%>
            <%--<asp:Button ID="btnSaveas" Text="Save as" ClientIDMode="Static" runat="server" OnClick="btnSaveas_Click" />&nbsp;&nbsp;--%>
            <asp:Button ID="btnSaveas" Text="Save as" ClientIDMode="Static" runat="server" OnClientClick="OpenPopupCriteriaNew(); return false;" OnClick="btnSaveas_Click" />&nbsp;&nbsp;
            <%--********************************--%>
            <asp:Button ID="btnDelete" ClientIDMode="Static" Text="Delete" runat="server" OnClick="btnDelete_Click" />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="lblStation" Text="Station:" runat="server"></asp:Label>
        </td>
        <td colspan="2">
            <asp:RadioButton runat="server" ID="rdbStation" ClientIDMode="Static" GroupName="station" AutoPostBack="true" OnCheckedChanged="rdbStation_CheckedChanged" />
            <asp:DropDownList ID="ddlStation" ClientIDMode="Static" AutoPostBack="true" Width="178" runat="server" OnSelectedIndexChanged="ddlStation_SelectedIndexChanged">
            </asp:DropDownList>
            <asp:HiddenField ID="hidStation" runat="server" ClientIDMode="Static" />

            <asp:RadioButton runat="server" ID="rdbmorestation" ClientIDMode="Static" GroupName="station" AutoPostBack="true" OnCheckedChanged="rdbmorestation_CheckedChanged" />
            <asp:Button ID="btnMorestation" Text="Mores tation..." ClientIDMode="Static" runat="server" OnClick="btnMorestation_Click" />
            <div style="display:none;"><asp:Button ID="btnChangeCriteria" Text="ChangeCriteria" ClientIDMode="Static" runat="server" OnClick="btnChangeCriteria_Click" /></div>
            <div style="display:none;"><asp:Button ID="btnChangeStation" Text="btnChangeStation" ClientIDMode="Static" runat="server" OnClick="btnChangeStation_Click" /></div>
            <asp:HiddenField ID="hdnPersonHoldStationKye" runat="server" ClientIDMode="Static" />
        </td>
        
    </tr>
    <tr>
        <td>
            <asp:Label ID="lblDateRange" Text="Date Range" runat="server"></asp:Label>
        </td>
        <td>
            <asp:RadioButton runat="server" AutoPostBack="True" ClientIDMode="Static" GroupName="date" ID="rdbDateRange" OnCheckedChanged="rdbDateRange_CheckedChanged" />
            <asp:DropDownList ID="ddlDateRange" ClientIDMode="Static" Width="178" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlDateRange_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
        <td>
        </td>
    </tr>
    <tr>
        <td>
        </td>
        <td>
            <asp:RadioButton runat="server" ClientIDMode="Static" AutoPostBack="True" GroupName="date" ID="rdbByDate" Text="ByDate" OnCheckedChanged="rdbByDate_CheckedChanged" />
        </td>
        <td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="lblFrom" Text="From:" runat="server"></asp:Label>
        </td>
        <td colspan="2">
            <APJ:DateTextBox ID="dtbFrom" runat="server" />
            <asp:Label ID="lblTo" runat="server" Text="To"></asp:Label>
            <APJ:DateTextBox ID="dtbTo" runat="server" />
        </td>
    </tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>



